package com.learn.code.juc.vol;

/**
 * @author : 翌擎科技
 * @date : 2022/8/1 16:32
 */
public class VolatileTest {
    private volatile static int result1 = 0;

    public static void main(String[] args) {
        System.out.println("----------------------------------------------------");
        int result = 0;
        for (int i = 0; i < 100; i++) {
            result = result + 1;
        }
        System.out.println(result);

        for (int i = 0; i < 100; i++) {
            new Thread(() -> {
                result1 = result1 + 1;
            }).start();
        }
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(result1);

        System.out.println("----------------------------------------------------");
    }


}
